package core.pathfinder;

import java.awt.Point;

import utils.Properties;

public class RoutePoint {
	int xpos;
	int ypos;
	int mapx;
	int mapy;
	
	
	public RoutePoint father;
	public boolean visited;
	public int G;
	public int H;
	public int C;

	public RoutePoint(int x, int y) {
		xpos = x;
		ypos = y;
		mapx = x / Properties.TILE_WIDTH;
		mapy = y / Properties.TILE_HEIGHT;
	}
	
	public RoutePoint(Point p){
		xpos = p.x;
		ypos = p.y;
		mapx = xpos/Properties.TILE_WIDTH;
		mapy = ypos/Properties.TILE_HEIGHT;
	}

	public int compareTo(RoutePoint other) {
		if (other.xpos == this.xpos && other.ypos == this.ypos) {
			return 1;
		} else {
			return 0;
		}
	}

	public int getXpos() {
		return xpos + 16;
	}

	public void setXpos(int xpos) {
		this.xpos = xpos;
	}

	public int getYpos() {
		return ypos +16;
	}

	public void setYpos(int ypos) {
		this.ypos = ypos;
	}

	public Point getPosition() {
		return new Point(xpos, ypos);
	}

	public void calculateG(){
		G = father.G + C;
	}
	
	public void calculateH(int ex , int ey){
		H = Math.abs(ex - this.mapx ) + Math.abs(ey - this.mapy);
	}
	
	public int getF(){
		return G + H;
	}
	
}
